package com.hh.utils;

import com.hh.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class ScheduledTask {
    @Autowired
    StatisticsDailyService service;

    // 每天凌晨1点执行
    @Scheduled(cron = "0 0 1 * * ?")
    public void getFontDate(){
        Date date = DateUtil.addDays(new Date(), -1);

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String fontDate = format.format(date);
        service.getRegisterCount(fontDate);
    }
}
